
#ifndef __SYSTEM_H_
#define __SYSTEM_H_

#include <stdio.h>
#include <stdbool.h>
#include <cJSON.h>
#include <syslog.h>
#include <stdarg.h>

void system_init(void);
void millisecond_sleep(unsigned long milliseconds);
void second_sleep(unsigned int seconds);
int isFileExists(const char *path);
int myexec(char *command, char *result, int *maxline);
void thread_sigmask(void);
void create_thread(void *(*start_routine)(void *param), void *param);
int ethernet_not_connect(char *ifname);
char* get_eth_mac(char *ifname, char *mac);
char* get_eth_ip(char *ifname, char *ip);
int set_time(char *date);
int string2hex(unsigned char *dest, char *src);
int string2hex_reverse(unsigned char *dest, char *src);
void hex2string(char *dest, unsigned char *src, int srclen);
void hex2string_lowercase(char *dest, unsigned char *src, int srclen);

void save_root_to_file(cJSON *root, char *file_name);
cJSON *parse_root_from_file(char *file_name);
void free_root(cJSON *root);

long long get_microsecond(void);
long long get_millisecond(void);
long long generate_msgid(void);

int charset_convert(const char *from_charset, const char *to_charset, char *in_buf, size_t in_left, char *out_buf, size_t out_left);
int charset_convert_UTF8_TO_GB2312(char *in_buf, int in_left, char *out_buf, int out_left);

void log_printf(const char *fmt,...);

int get_current_minute(void);
int get_current_second(void);
int get_current_hour(void);

int gpio_export(int pin);

int gpio_direction_in(int pin);
int gpio_direction_out(int pin);

int gpio_value_output(int pin, int level);

int get_gpio_value(int pin);

int get_file_size(char *file_name);

void get_serial_number(char * Serial);

int get_file_md5sum(char *filename, char *md5sum);

int isLinkFile(char *filename);

#endif //__SYSTEM_H_
